package com.zzxx.mapper;

import com.zzxx.pojo.Product;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ProductMapper {
	@Select("select * from product")
	public List<Product> findAll();

	@Insert("insert into product (id,productNum,productName,cityName,departureTime,productDesc,productStatus,productPrice)" +
	"values(#{id},#{productNum},#{productName},#{cityName},#{departureTimeStr},#{productDesc},#{productStatus},#{productPrice})")
	void add(Product product);

	@Delete("delete from product where id = #{id}")
	void deleteById(String id);

	@Select("select * from product where id = #{id}")
	Product findById(String id);
	@Update("update product set productNum=#{productNum},productName=#{productName},cityName=#{cityName}," +
	"departureTime=#{departureTime},productDesc=#{productDesc},productStatus=#{productStatus},productPrice=#{productPrice} where id=#{id}")
	void update(Product product);

	@Update("update product set productStatus = #{state} where id = #{id}")
	void updateStatusById(@Param("id") String id, @Param("state") Integer state);
}
